<template>
	<div>
		<div class="header">



			<!-- title="智能供佛系统" -->
			<van-nav-bar style="  background: linear-gradient(90deg, #FF6D00,#FFB500 , #FF6D00);height: 80px;line-height: 80px;">

				<span class="title" slot="title">录入指纹</span>
				
			</van-nav-bar>
			<!-- <van-nav-bar title="智能供佛系统" style=" background: url(./images/系统标题部分.png);height: 80px;line-height: 80px; background-size:1142px 80px;background-repeat:no-repeat;">
				<van-icon name="search" slot="right" />
			</van-nav-bar> -->
		</div>



		<!-- /////////////////////////////////////////////////////////// -->
		<div class="content" style=" width:100%; background:url(./images/background.png) no-repeat; background-size:100% 100%; ">
<!-- 
			<h1 style="margin-top: 250px; text-shadow: 2px 0px 10px #FFFFFF;" v-if="flag">
				请将录入指纹的手指轻按在感应器上. . .
			</h1>
			<h1 style="margin-top: 250px; text-shadow: 2px 0px 10px #FFFFFF;" v-else>
				未捕获到有用指纹
			</h1> -->
			
			
			<h1 style="margin-top: 250px; text-shadow: 2px 0px 10px #FFFFFF;" >
				{{mes}}
			</h1>
					



		</div>
	</div>

</template>

<script>
	export default {

		data() {
			return {
				mes:"请将录入指纹的手指轻按在感应器上. . ."
				
			}
		},
		methods: {

		},
		created() {
			this.axios.post('http://localhost:8088/finger/add',this.$store.getters.getUser.id)
				.then((response) =>{
					console.log(response);
					if (response.data == 0) {//关于后台返回码，参看添加指纹页面
						this.mes="识别错误，请重试！";
				
						//过一会
						let card_timeoutId = setTimeout(() => {
							this.$router.push("consumer");
							this.$toast.fail({
								message: '绑定失败！'
							});
						}, 2000);
						
						
					} else if(response.data ==-2){
						
						this.mes="超时，未捕获到有用指纹!";
						//过一会
						let card_timeoutId = setTimeout(() => {
							this.$router.push("consumer");
							this.$toast.fail({
								message: '绑定失败！'
							});
						}, 2000);
					}else if(response.data ==1){
						this.mes="绑定成功！";
						//////////////////////////////////
						///////////////////////////////
						this.axios.post('https://mianmianshi.com/cms/temple/client/updateUser', {
								'where': { //修改当前用户
									'id': this.$store.getters.getUser.id
								},
								update: { //更新属性
									fingerprint: 'Y'
								}
						
							})
							.then((res) => {
								if (res) { //成功修改
									this.$toast.success({
										message: '绑定成功！'
									});
									this.$router.push("login");
						
						
						
								} else {
									this.$router.push("consumer");
									this.$toast.fail({
										message: '服务繁忙，请稍后重试！'
									});
								}
						
							})
							.catch(function(error) {
								console.log(error);
							});
						//
						
						////////////////////////////////
						//alert(response.data);
					}

				})
				.catch(function(error) {
					console.log(error);
				});
		}



	}
</script>

<style>
	.xundeng {
		position: absolute;
		height: 100%;
		width: 100%;
		background: url(../../public/images/xundeng.png) no-repeat;
		background-size: 100% 100%;
	}
</style>
